/**
 * Created by lgc on 2017/10/28.
 */
import {localLogin} from '../../service'
import * as types from '../mutation-types'
import Cookies from 'js-cookie';


// initial state
const state = {
  items:[]
}

// getters
const getters = {
}
export const LocalLogin = ({ commit }) => {

}
// actions
const actions = {
  LocalLogin({ commit },data){
    localLogin(data).then(response => {
      if(!response.ok){
        return commit(types.FAILURE_GET_LOGINS)
      }
      commit(types.SUCCESS_GET_LOGINS, response.data)
    }, response => {
      commit(types.FAILURE_GET_LOGINS)
    })
  }
}

// mutations
const mutations = {
  [types.FAILURE_GET_LOGINS](state){
    console.info("error");
    state.items = []

  },
  [types.SUCCESS_GET_LOGINS](state,data){
    console.info("ok");
    console.info(data);
    state.items = data;
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
